﻿// -----------------------------------------------------------------------
// <copyright file="AppConfigurationSection.cs" company="EPAM Systems">
////Copyright (c) EPAM Systems, 2012. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------

namespace MBOP.Configuration.ConfigElements
{
	#region Usings

	using System;
	using System.Collections.Generic;
	using System.Configuration;
	using System.Linq;
	using System.Text;

	#endregion

	/// <summary>
	/// Provides the application settings from config file.
	/// </summary>
	public class AppConfigurationSection : ConfigurationSection
	{
		#region Constants

		/// <summary>
		/// Represents application configuration section name in config.
		/// </summary>
		public const string APPLICATION_CONFIGURATION_SECTION_NAME = "appConfiguration";

		#endregion

		#region Private Fields
		/// <summary>
		/// Represents app config.
		/// </summary>
		private static AppConfigurationSection _config = (AppConfigurationSection)ConfigurationManager.GetSection(APPLICATION_CONFIGURATION_SECTION_NAME);

		/// <summary>
		/// Prevents a default instance of the <see cref="AppConfigurationSection"/> class from being created.
		/// </summary>
		private AppConfigurationSection()
		{
		}

		#endregion

		#region Properties

		/// <summary>
		/// Gets or sets the administrators
		/// </summary>
		[ConfigurationProperty("administrators")]
		public AdminElementCollection Administrators
		{
			get
			{
				return (AdminElementCollection)this["administrators"];
			}

			set
			{
				this["admnistrators"] = value;
			}
		}

		/// <summary>
		/// Gets or sets the allowed image formats
		/// </summary>
		[ConfigurationProperty("imageFormats")]
		public ImageFormatElementCollection ImageFormats
		{
			get
			{
				return (ImageFormatElementCollection)this["imageFormats"];
			}

			set
			{
				this["imageFormats"] = value;
			}
		}

		/// <summary>
		/// Gets or sets the application modules.
		/// </summary>
		[ConfigurationProperty("modules")]
		public ModulesElement AppModules
		{
			get
			{
				return (ModulesElement)this["modules"];
			}

			set
			{
				this["modules"] = value;
			}
		}

		/// <summary>
		/// Gets or sets the notification services
		/// </summary>
		[ConfigurationProperty("notificationServices")]
		public NotificationServicesElement NotificationServices
		{
			get
			{
				return (NotificationServicesElement)this["notificationServices"];
			}

			set
			{
				this["notificationServices"] = value;
			}
		}

		/// <summary>
		/// Gets or sets the distributed services.
		/// </summary>
		[ConfigurationProperty("distributedServices")]
		public DistributedServicesElement DistributedServices
		{
			get
			{
				return (DistributedServicesElement)this["distributedServices"];
			}

			set
			{
				this["distributedServices"] = value;
			}
		}

		#endregion

		#region Public Methods

		/// <summary>
		/// Gets the instance of <see cref="AppConfigurationSection"/> class.
		/// </summary>
		/// <returns>The <see cref="AppConfigurationSection"/> instance.</returns>
		public static AppConfigurationSection GetInstance()
		{
			return _config;
		}

		#endregion
	}
}
